<template>
  <component :is="lazyComponent" v-if="lazyComponent" />
</template>

<script setup>
import { ref, computed, onMounted, defineAsyncComponent } from "vue";
import { useStore } from "@/store/index";
const lazyComponent = ref(null);
const store = useStore();
const loadComponent = async (url) => {
  // 使用 defineAsyncComponent 和 import() 函数懒加载组件
  let LazyComponent = null
  if(store.isPc==2){
    LazyComponent = defineAsyncComponent(() => import('@/components/mobileComponent/seoCustomer/mobile.vue'));
  }else{
    LazyComponent = defineAsyncComponent(() => import('@/components/mobileComponent/seoCustomer/pc.vue'));
  }
  lazyComponent.value = LazyComponent;
};
watch(() => store.isPc, (newVal) => {
  loadComponent()
}, {immediate: true})

onMounted(() => {
  const element = document.getElementById("app");
  element.scrollTop = 0;
});
</script>
<style lang="scss" scoped></style>
